package com.rf.richfitwheel.admin.sys.dao;

import com.rf.richfitwheel.admin.sys.model.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface OrgMapper {
    long countByExample(OrgExample example);

    int deleteByExample(OrgExample example);

    int deleteByPrimaryKey(String id);

    int insert(Org record);

    int insertSelective(Org record);

    List<Org> selectByExample(OrgExample example);

    Org selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") Org record, @Param("example") OrgExample example);

    int updateByExample(@Param("record") Org record, @Param("example") OrgExample example);

    int updateByPrimaryKeySelective(Org record);

    int updateByPrimaryKey(Org record);

    List<Org> selectCodeAndLength();

    void updateOrgLeave(Org orgLevel);

//    List<Org> getOrgListByCode(Org Org);

//    List<Org> selectOrgCodeByName(String orgName);

    List<User> selectAllUserById(String thirdid);

    /**
     * @param orgCode
     * @功能描述: 根据orgcode 获取org
     * @auther: jiaozhongcai
     * @date: 2021/6/8 11:14
     * @return: Org
     */
    Org getOrgIdCode(String orgCode);


    /**
     * @param thirdid
     * @功能描述: 查询是否在多个单位下
     * @auther: jiaozhongcai
     * @date: 2021/6/8 14:30
     * @return: List<User>
     */
    List<User> getUserBythirdId(String thirdid);

    /**
     * 根据部门id查询父机构信息
     */
    List<Org> getParentOrgByOrgId(String orgId);

    List<Org> getParentOrgList(@Param("orgIds") List<String> orgIds);

    List<Org> getSelfOrgDeptList(@Param("orgIds") List<String> orgIds);

    List<Map<String, String>> getAllUserOrgCode();

    void updateUserOrgCode(Map<String, String> map);

    EntVo getEntVoByUserId(String orgId);

    EntVo getUpperEntVoByOrgId(String id);

    List<EntVo> getLowerEntVosByOrgId(String id);

//    String getCurrentAndChildrenOrgCode(@Param("orgId") String orgId);

    Set<String> getCurrentAndChildrenOrgCodeList(@Param("orgId") String orgId);

    List<Map<String, Object>> getCurrentAndChildrenOrgInfoListByOrgCode(String orgCode);

    List<Org> getCurrentAndChildrenOrgList(Map<String, Object> params);
    List<Org> getCurrentAndChildrenOrgListHasOrgCode(Map<String, Object> params);

    //根据机构编码获取本级及下级单位的编码
    List<String> getCurrentAndBelowOrgCodeListByOrgCode(@Param("orgCode") String orgCode);

    List<Org> getOrgListByOrgNameRight(Map<String, Object> param);

    List<OrgHasChildren> selectByExampleHashChildren(OrgExample example);

    List<OrgHasChildren> selectAllOrgsByMainId(Map<String, Object> params);

    /**
     *
     * @param example
     * @return
     */
    List<OrgHasChildren> selectByExampleHashChildrenExcludeDept(OrgExample example);

    /**
     * 用户所有管辖单位,列表
     * @param param
     * @return
     */
    List<Org> queryMngListIncludeDept(Map<String, Object> param);

    /**
     * 根据机构id查询所有下级机构
     * @param org
     * @return
     */
    List<OrgHasChildren> queryOrgsListExcludeDeptByParentId(Org org);

    /**
     * AVIC 应收账款项目
     * 当前登录用户所属机构id，查其下属的所有公司
     */
    List<Org> querySubOrgByParentId(Org org);


    /**
     * 向上查询直至顶级
     * @param param {orgIds:List<String>} 要查询的机构id集合
     * @return
     */
    List<Org> getOrgListByOrgIdUpHasSelf(Map<String, Object> param);

    /**
     * 向上查询直至顶级，不包含自己
     * @param param {orgIds:List<String>} 要查询的机构id集合
     * @return
     */
    List<Org> getOrgListByOrgIdUpHasNoSelf(Map<String, Object> param);
    
    
    /**
     * 向上查询直至顶级，不包含自己
     * @param param {orgIds:List<String>} 要查询的机构id集合
     * @return
     */
    List<OrgHasParent> getOrgListByOrgIdHasParentSelf(Map<String, Object> param);

    List<Org> selectAdminByExample(OrgExample example);
}
